#include "ai_pingpong.h"
#include "pingpong.h"

AI_pingpong::AI_pingpong(Ball* playball, Paddle* aiPaddle)
{
    this->playball = playball;
    this->aiPaddle = aiPaddle;
}

void AI_pingpong::movePaddle()
{
    if (playball->pos().y() > aiPaddle->pos().y() && abs(playball->pos().y()-aiPaddle->pos().y()) >=30) {
        aiPaddle->goDown();
    }
    else if (abs(playball->pos().y()-aiPaddle->pos().y()) >=30){
        aiPaddle->goUp();
    }
}
AI_pingpong::~AI_pingpong()
{
    delete playball;
    delete aiPaddle;
}
